/*
 * This file is part of Space Invaders: Rehash
 * Copyright (C)2007 Vicent Marti (tanoku@gmail.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __MENU_H__
#define __MENU_H__

#include "SDL.h"
#include <stdio.h>
#include <string>
#include <vector>

#include "timer.h"
#include "main.h"

#define MENU_MAIN 0
#define MENU_NEWGAME 1
#define MENU_OPTIONS 2
#define MENU_CONTINUE 3
#define MENU_CONFIGURE 4
#define MENU_MAX 5

#define MENU_GFX_ROWS 4
#define MENU_GFX_SIZE 200

#define ANIMATION_CHANGE_TIME 550
#define ANIMATION_FADE_TIME 3500
#define ANIMATION_SCROLL_TIME 1000

class MainMenu : public SI_Screen
{
	int m_menu;
	int m_lastMenu;

	int m_mainMenu_selected;
	int m_newgameMenu_selected;
	int m_cfgMenu_selected;
	bool m_newgameMenu_customEnabled;

	Uint32 m_lastKeystroke;

	int m_customGameRules;

	bool m_finished;
	int m_scrToLoad;

	int m_animation;
	SimpleTimer m_animationTimer;
	
	SimpleTimer m_continueTextTimer;
	char m_continueText[64];
	
	char m_levelPass[8];
	int m_editPass;
	
public:
	MainMenu();
	
	bool renderScrollingMenu( int &x, int &y, int &w, int &h );
	void render_newgame();
	void render_cfg();
	void render_load();
	void render();

	void renderMenuRow( int row, int x_offset );

	void changeMenuSelection( int mov );
	void moveToMenuScreen( int scr );
	
	void onContinueKeypress( int key );
	void onCfgKeypress( int key );
	void onNewGameKeypress( int key );
	
	const char *getCustomGameRuleString( int rule );
	void changeCustomGameRule( int rule );
	
	const char *getOptionString( int option );
	
	bool finished() { return m_finished; }
	void tick();
	void onEvent( SDL_Event *event );
	int getNextScreen()
	{
		return m_scrToLoad;
	}
};

#endif
